package com.pro.framework.mtq.service.multiwrapper.entity;

import com.pro.framework.api.database.*;
import com.pro.framework.api.database.page.IPageInput;
import com.pro.framework.api.database.page.PageInput;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
public interface IMultiService<T> {
    boolean save(T entity);
    default boolean save(IContext context, T entity) {
        return this.save(entity);
    }
    // 保存或更新实体
    boolean saveOrUpdate(T entity);
    default boolean saveOrUpdate(IContext context, T entity) {
        return this.saveOrUpdate(entity);
    }

    boolean updateById(T entity);
    default boolean updateById(IContext context, T entity) {
        return this.updateById(entity);
    }

    // 根据主键删除实体
    boolean removeById(Class<?> clazz, Serializable id);
    default boolean removeById(IContext context, Class<?> clazz, Serializable id) {
        return this.removeById(clazz, id);
    }


    boolean saveBatch(Collection<T> entityList);
    // 根据主键删除实体
    default boolean saveBatch(IContext context, Collection<T> entityList) {
        return this.saveBatch(entityList);
    }


    boolean removeBatchByIds(Collection<?> list);
    default boolean removeBatchByIds(IContext context, Collection<?> list) {
        return this.removeBatchByIds(list);
    }

    boolean updateBatchById(Collection<T> list);
    default boolean updateBatchById(IContext context, Collection<T> list) {
        return this.updateBatchById(list);
    }

    IMultiPageResult<T> selectPage(String entityClassNames, IPageInput pageInput, Map<String, Object> paramMap, TimeQuery timeQuery);
    default IMultiPageResult<T> selectPage(IContext context, String entityClassNames, IPageInput pageInput, Map<String, Object> paramMap, TimeQuery timeQuery) {
        return this.selectPage(entityClassNames, pageInput, paramMap, timeQuery);
    }

    T selectOneById(String entityClassName, Serializable id);
    default T selectOneById(IContext context, String entityClassName, Serializable id) {
        return this.selectOneById(entityClassName, id);
    }

    //    List<T> selectList(String entityClassNames, Map<String, Object> paramMap, TimeQuery timeQuery, List<String> selects, List<String> selectMores, List<String> selectLess);
    List<T> selectList(String entityClassNames, Map<String, Object> paramMap, TimeQuery timeQuery, List<String> selects, List<String> selectMores, List<String> selectLess, PageInput pageInput);
    default List<T> selectList(IContext context, String entityClassNames, Map<String, Object> paramMap, TimeQuery timeQuery, List<String> selects, List<String> selectMores, List<String> selectLess, PageInput pageInput) {
        return this.selectList(entityClassNames, paramMap, timeQuery, selects, selectMores, selectLess, pageInput);
    }

    List<AggregateResult> selectCountSum(String entityClassName, IPageInput pageInput, Map<String, Object> paramMap, TimeQuery timeQuery, GroupBy groupBy);
    default List<AggregateResult> selectCountSum(IContext context, String entityClassName, IPageInput pageInput, Map<String, Object> paramMap, TimeQuery timeQuery, GroupBy groupBy) {
        return this.selectCountSum(entityClassName, pageInput, paramMap, timeQuery, groupBy);
    }

    T selectOne(String entityClassName, IPageInput pageInput, Map<String, Object> paramMap, TimeQuery timeQuery);
    default T selectOne(IContext context, String entityClassName, IPageInput pageInput, Map<String, Object> paramMap, TimeQuery timeQuery) {
        return this.selectOne(entityClassName, pageInput, paramMap, timeQuery);
    }
}
